<?php

namespace App\Http\Controllers;

use App\Http\Requests\Platform\UploadRequest;
use App\Http\Resources\BaseResource;
use App\Repositories\Contracts\PlatformInterface;
use Illuminate\Http\Request;
use MakeRep\Controllers\BaseController;

class PlatformController extends BaseController
{

    public function __construct(PlatformInterface $interface)
    {
        parent::__construct($interface);
    }

    /**
     * 政策一键上传
     * @param Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application|\Illuminate\View\View
     */
    public function upload(Request $request){

        return view('platform.upload');
    }

    /**
     * 上传政策代码
     * @param UploadRequest $request
     * @return BaseResource|array
     */
    public function ajaxUpload(Request $request){

        $res = $this->interface->platformUploadPolicy($request->all());

        if (is_string($res)) {

            return ['errcode'=>3001,'errmsg' => $res];
        }

        return new BaseResource([]);
    }
}